﻿<UserControl x:Class="Mengsk.ProxyDelivery.App.UI.Delivery.DeliveryTemplateUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:delivery="clr-namespace:Mengsk.ProxyDelivery.App.UI.Delivery"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="1200" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <delivery:IBoolConverter x:Key="boolConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <Button Name="btnRefresh" Margin="3" Click="btnRefresh_Click" Content="获取运费模板" Width="100" HorizontalAlignment="Left"/>
            <Button Name="btnAdd" Margin="3" Click="btnAdd_Click" Content="新增运费模板" Width="100" HorizontalAlignment="Left"/>
        </StackPanel>

        <ListBox Grid.Row="1" Name="lstDeliveryTemplates"  ScrollViewer.CanContentScroll="False">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <GroupBox Margin="3,0,0,0">
                                    <GroupBox.Header>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <StackPanel Grid.Column="0" Orientation="Horizontal" >
                                                <TextBlock  Text="运费编号" Margin="3" VerticalAlignment="Center"/>
                                                <TextBlock  Text="{Binding Source.Id}" Margin="3" VerticalAlignment="Center"/>
                                                <TextBlock   Text="{Binding Description}" Margin="3" VerticalAlignment="Center" MinWidth="150"/>
                                                <TextBlock   Text="{Binding Source.Enabled, Converter={StaticResource ResourceKey=boolConverter},ConverterParameter=   当前状态：禁用|   当前状态：启用}" Margin="3" Width="120" VerticalAlignment="Center"/>
                                                <TextBlock   Text="{Binding Source.WebShowEnabled, Converter={StaticResource ResourceKey=boolConverter},ConverterParameter=   主页显示：禁用|   主页显示：启用}" Margin="3" Width="120" VerticalAlignment="Center"/>
                                                <TextBlock   Text="最后更新于:" Margin="3" VerticalAlignment="Center"/>
                                                <TextBlock  Text="{Binding Source.UpdateTime,StringFormat=yyyy-MM-dd HH:mm:ss}" Margin="3" VerticalAlignment="Center"/>
                                                <TextBlock  Text="面单费用:" Margin="3" VerticalAlignment="Center"/>
                                                <TextBlock  Text="{Binding Source.PaperMoney}" Margin="3" VerticalAlignment="Center"/>
                                            </StackPanel>
                                            <StackPanel Grid.Column="2" Orientation="Horizontal">
                                                <Button  Name="btnUp" Content="上" Margin="3" VerticalAlignment="Center" Click="btnUp_Click" DataContext="{Binding}"/>
                                                <Button   Name="btnDown" Content="下" Margin="3" VerticalAlignment="Center" Click="btnDown_Click" DataContext="{Binding}"/>
                                                <Button  Name="btnDisabled" Content="{Binding Source.Enabled,Converter={StaticResource ResourceKey=boolConverter},ConverterParameter=启用|禁用}" Width="60" Foreground="Green" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnDisabled_Click"/>
                                                <Button  Name="btnDisabledWebShow" Content="{Binding Source.WebShowEnabled,Converter={StaticResource ResourceKey=boolConverter},ConverterParameter=启用主页显示|禁用主页显示}" Width="60" Foreground="Green" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnDisabledWebShow_Click"/>

                                                <Button   Name="btnEdit" Content="修改" Width="60" Foreground="Green" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnEdit_Click"/>
                                                <Button   Name="btnDelete" Content="删除" Width="60" Foreground="Green" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnDelete_Click"/>
                                            </StackPanel>
                                        </Grid>
                                    </GroupBox.Header>

                                    <DataGrid ItemsSource="{Binding Source.Areas}" IsReadOnly="True" HeadersVisibility="All" GridLinesVisibility="All" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" SelectionMode="Single"  SelectionUnit="FullRow">
                                        <DataGrid.Columns>
                                            <DataGridTextColumn Header="目地城市" Binding="{Binding Area}" Width="550"/>
                                            <DataGridTextColumn Header="首重" Binding="{Binding Start}" Width="Auto"/>
                                            <DataGridTextColumn Header="首重运费" Binding="{Binding StartPrice}" Width="Auto"/>
                                            <DataGridTextColumn Header="续重" Binding="{Binding Step}" Width="Auto"/>
                                            <DataGridTextColumn Header="续重运费" Binding="{Binding StepPrice}" Width="Auto"/>
                                        </DataGrid.Columns>
                                    </DataGrid>
                                </GroupBox>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    </Grid>
</UserControl>
